#!/bin/sh
#shellcheck source=../environment.in
. ./environment

# reset dbdriver in case we're rerunning the test with another driver
sed \
  -i \
  -e 's/dbdriver =.*/dbdriver = XXX_REPLACE_WITH_DATABASE_DRIVER_XXX/' \
  etc/susan/susan-dir.d/catalog/*.conf 2>/dev/null

${scripts}/susan-config initialize_database_driver
. ${rscripts}/functions

print_debug "drop database \"${db_name}\" (${DBTYPE})"
${scripts}/drop_susan_database ${DBTYPE} >/dev/null 2>&1

print_debug "creating database \"${db_name}\" (${DBTYPE})"
${scripts}/create_susan_database ${DBTYPE} >/dev/null 2>&1
${scripts}/make_susan_tables ${DBTYPE} >/dev/null 2>&1
${scripts}/grant_susan_privileges ${DBTYPE} >/dev/null 2>&1

exit 0
